home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / MPW / gzip 1.2.2 / cextras-1.0 / dirent.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-11  |  2.0 KB  |  76 lines  |  [TEXT/MPS ]

  1. /*
  2.     dirent.h -- file system independant directory access for MPW.
  3.  
  4.     Copyright (c) 1993 Anthony C. Ard.
  5.  
  6.     This program is free software; you can redistribute it and/or
  7.     modifiy it under the terms of the GNU General Public License
  8.     as published by the Free Software Foundation; either version 2
  9.     of the License, or (at your option) any later version.
  10.     
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14.     GNU General Public License for more details.
  15.     
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. #ifndef dirent_h
  22. #define dirent_h
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. #ifndef NULL
  29. #define    NULL    0
  30. #endif
  31.  
  32. struct dirent {
  33.     long            d_ino;            /* inode number of entry */
  34.     off_t            d_off;            /* offset of disk directory entry */
  35.     unsigned short    d_reclen;        /* length of this record */
  36.     char            d_name[255];    /* name of file */
  37. };
  38.  
  39. /* The following nonportable ugliness could have been avoided by defining
  40.    DIRENTSIZ and DIRENTBASESIZ to also have (struct dirent *) arguments.
  41.    There shouldn't be any problem if you avoid using the DIRENTSIZ() macro. */
  42.  
  43. #define    DIRENTBASESIZ        (((struct dirent *)0)->d_name \
  44.                             - (char *)&((struct dirent *)0)->d_ino)
  45.  
  46. #define    DIRENTSIZ( namlen )    ((DIRENTBASESIZ + sizeof(long) + (namlen)) \
  47.                             / sizeof(long) * sizeof(long))
  48.  
  49. #define    MAXNAMLEN            63
  50.  
  51. #ifndef NAME_MAX
  52. #define    NAME_MAX            (MAXNAMLEN - 1)
  53. #endif
  54.  
  55. #define    DIRBUF                8192
  56.  
  57. typedef struct {
  58.     int        dd_fd;
  59.     int        dd_loc;
  60.     int        dd_size;
  61.     char    *dd_buf;
  62. } DIR;
  63.  
  64. DIR *opendir( char *dirname );
  65. struct dirent *readdir( register DIR *dirp );
  66. off_t telldir( DIR *dirp );
  67. void seekdir( register DIR *dirp, register off_t loc );
  68. void rewinddir( register DIR *dirp );
  69. int closedir( register DIR *dirp );
  70.  
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74.  
  75. #endif dirent_h
  76.